package com.csesteel.crm.service.impl;

import com.csesteel.crm.dao.CrmPriviledgeDao;
import com.csesteel.crm.domain.CrmPriviledge;
import com.csesteel.crm.service.CrmPriviledgeService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Administrator on 2015/5/23 0023.
 */
@Service
public class CrmPriviledgeServiceImpl implements CrmPriviledgeService {

    private Log logger = LogFactory.getLog(CrmPriviledgeServiceImpl.class);

    @Autowired
    private CrmPriviledgeDao crmPriviledgeDao;

    @Transactional
    public CrmPriviledge getCrmPriviledge(Integer id) {
        return crmPriviledgeDao.get(CrmPriviledge.class,id);
    }

    @Transactional
    public void saveCrmPriviledge(CrmPriviledge crmPriviledge) {
        crmPriviledgeDao.save(crmPriviledge);
    }

    @Transactional
    public void updateCrmPriviledge(CrmPriviledge crmPriviledge) {
        crmPriviledgeDao.update(crmPriviledge);
    }

    @Transactional
    public void deleteCrmPriviledge(Integer id) {
        crmPriviledgeDao.delete(CrmPriviledge.class,id);

    }
    @Transactional
    public List<CrmPriviledge> findAllCrmPriviledge() {
        return crmPriviledgeDao.findAll(CrmPriviledge.class);
    }

    @Transactional
    public List<CrmPriviledge> findAllCrmPriviledgeByPage(int pageNo, int pageSize, String name) {
        return crmPriviledgeDao.findAllCrmPriviledgeByPage(pageNo,pageSize,name);
    }

    @Transactional
    public long findCount(String name) {
        return crmPriviledgeDao.findCountUsersWithParams(name);
    }

    @Transactional
    public void savePriviledgeByMenu(Integer priviledgeId, Integer menuId) {
        crmPriviledgeDao.savePriviledgeByMenu(priviledgeId,menuId);
    }

    @Transactional
    public void deletePriviledgeByMenu(Integer priviledgeId) {
        crmPriviledgeDao.deletePriviledgeByMenu(priviledgeId);
    }
}
